/**
 * @author Tobias Boehm
 *
 * 24.05.2011
 */
package org.anddev.andengine.extension.tbsengine.message.server.preparematch;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.anddev.andengine.extension.tbsengine.match.playerslot.BaseServerPlayerSlot;
import org.anddev.andengine.extension.tbsengine.message.server.AbsServerMatchMessage;

/**
 * This is the base class for developing new player slot related server messages.
 * 
 * @author Tobias Boehm
 *
 */
public abstract class AbsServerMatchpreparationSlotMessage extends AbsServerMatchMessage {

	protected long mSlotID = -1;

	protected abstract void onReadTransmissonMatchSlotData(final DataInputStream pDataInputStream) throws IOException;
	
	protected abstract void onWriteTransmissonMatchSlotData(final DataOutputStream pDataOutputStream) throws IOException;
	
	
	@Override
	protected void onReadTransmissonMatchData(final DataInputStream pDataInputStream) throws IOException {
		
		this.mSlotID = pDataInputStream.readLong();
		
		this.onReadTransmissonMatchSlotData(pDataInputStream);
	}
	
	@Override
	protected void onWriteTransmissonMatchData(final DataOutputStream pDataOutputStream) throws IOException {
		
		pDataOutputStream.writeLong(this.mSlotID);
		
		this.onWriteTransmissonMatchSlotData(pDataOutputStream);
	}

	/**
	 * @return the mSlotID
	 */
	public long getSlotID() {
		return mSlotID;
	}

	/**
	 * @param mSlotID the mSlotID to set
	 */
	public void setSlot(final BaseServerPlayerSlot mSlot) {
		this.mSlotID = mSlot.getSlotID();
	}
}
